<!--合同管理页面-->
<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.sn" placeholder="合同单号" style="width: 180px"></el-input>
				</el-form-item>
				<el-form-item>
					<el-input v-model="filters.customerName" placeholder="客户姓名" style="width: 100px"></el-input>
				</el-form-item>
				<el-form-item>
					<el-date-picker type="datetime" placeholder="开始时间"
									v-model="filters.startTime"

									style="width: 190px;"/>
				</el-form-item>
				<el-form-item label-width="50px">
					<el-date-picker type="datetime" placeholder="结束时间"
									v-model="filters.endTime"
									format="yyyy-MM-dd HH:mm:ss"
									style="width: 190px;"/>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getContracts">查询</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="info" v-on:click="getAllDepositOrders">清空查询</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="handleAdd">新增</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="contracts" highlight-current-row stripe border v-loading="listLoading"
				  @selection-change="selsChange" style="width: 100%"
				 >
			<el-table-column type="selection" width="50px">
			</el-table-column>
			<el-table-column type="index" width="70px" label="编号">
				<!--自定义编号-->
				<template scope="scope">
					<span>{{(page - 1) * 10 + scope.$index + 1}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="sn" label="合同单号" width="170px">
			</el-table-column>
			<el-table-column   label="签订时间" width="180px" sortable>
				<!--使用过滤器的写法 scope.row.字段名-->
				<template slot-scope="scope">
					<span>{{ scope.row.signTime | formatDate('yyyy-MM-dd HH:mm:ss') }}</span>
				</template>
			</el-table-column>
			<el-table-column prop="sum" label="总金额(元)" width="130px" sortable>
			</el-table-column>
			<el-table-column prop="customer.name" label="客户" width="90px">
			</el-table-column>
			<el-table-column prop="seller.username" label="营销人员" width="90px">
			</el-table-column>
			<el-table-column prop="intro" label="合同摘要" width="100px">
			</el-table-column>
			<el-table-column prop="tenant" label="所属租户" width="110px" sortable>
			</el-table-column>
			<el-table-column label="付款明细" fixed="right" width="80px">
				<template scope="scope">
					<el-button size="small" @click="dialogDetails(scope.$index, scope.row)">查看</el-button>
				</template>
			</el-table-column>
			<el-table-column label="操作" fixed="right" width="160px" align="center">
				<template scope="scope">
					<el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
					<el-button type="danger" size="small" @click="handleDel(scope.$index, scope.row)">删除</el-button>
				</template>
			</el-table-column>
		</el-table>

		<!--分页工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination layout="total,prev, pager, next,jumper" @current-change="handleCurrentChange" :page-size="10" :total="total" style="float:right;">
			</el-pagination>
		</el-col>

		<!--合同明细对话框-->
		<el-dialog title="合同付款明细" :visible.sync="dialogDetailsVisible" width="950px">
			<div >
				<el-button type="info"  size="small" @click="dialogDetailsVisible = false">取消</el-button>
				<el-button type="primary" size="small"  @click="handleAddDetail">添加</el-button>
			</div>
			<el-table :data="details">
				<el-table-column type="index" width="70px" label="编号"></el-table-column>
				<el-table-column property="contract.sn" label="所属合同" width="160"></el-table-column>
				<el-table-column property="payTime" label="付款时间" width="180">
					<!--使用过滤器的写法 scope.row.字段名-->
					<template slot-scope="scope">
						<span>{{ scope.row.payTime | formatDate('yyyy-MM-dd HH:mm:ss') }}</span>
					</template>
				</el-table-column>
				<el-table-column property="money" label="金额(元)" width="120"></el-table-column>
				<el-table-column property="scale" label="付款比例" width="120">
					<template slot-scope="scope">{{scope.row.scale}}%</template>
				</el-table-column>
				<el-table-column property="isPayment" label="是否付款" >
					<template scope="scope">
						<div v-if="scope.row.isPayment">
							<el-button size="small" type="success" icon="el-icon-success"></el-button>
						</div>
						<div v-else>
							<el-button size="small" type="danger" icon="el-icon-error" ></el-button>
						</div>
					</template>
				</el-table-column>
				<el-table-column label="操作" fixed="right" width="160px" align="center">
					<template scope="scope">
						<el-button size="small" @click="handleEditDetail(scope.$index, scope.row)">编辑</el-button>
						<el-button type="danger" size="small" @click="handleDelDetail(scope.$index, scope.row)">删除</el-button>
					</template>
				</el-table-column>
			</el-table>
			<div style="margin-top: 20px">
				<p><span style="color: #13ce66"> 已付金额:  {{contractTemp.detailsMoney}}元 &nbsp;  所占比例:  {{contractTemp.detailsScale}}% </span></p>
				<span style="color: #ff6d6d"> 剩余应付:  {{contractSum - contractTemp.detailsMoney}}元 &nbsp; 剩余比例:  {{100 - contractTemp.detailsScale}}%</span>
			</div>

			<!--添加合同明细的表单-->
			<el-dialog
					width="30%"
					title="添加合同明细"
					:visible.sync="handleAddContractDetail"
					append-to-body>
				<el-form :model="addDetail" label-width="90px" ref="addDetail" :rules="detailsFormRules">
					<!--格式化时间，可以选择日期和时分秒-->
					<el-form-item label="付款时间" prop="payTime" required>
						<el-date-picker type="datetime" placeholder="请选择时间"
										v-model="addDetail.payTime"
										format="yyyy-MM-dd HH:mm:ss"/>
					</el-form-item>
					<el-form-item label="付款比例(%)" >
						<el-input v-model="addDetail.scale" disabled></el-input>
					</el-form-item>
					<el-form-item label="金额(元)" prop="money" required>
						<el-input v-model.number="addDetail.money"></el-input>
					</el-form-item>

					<el-form-item label="是否付款" required prop="isPayment">
						<el-select v-model="addDetail.isPayment" filterable placeholder="请选择" >
							<el-option
									v-for="item in isPaymentList"
									:key="item.value"
									:label="item.label"
									:value="item.value">
							</el-option>
						</el-select>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button @click.native="handleAddContractDetail = false">取消</el-button>
					<el-button type="primary" @click.native="addSubmitDetail" :loading="addLoading">提交</el-button>
				</div>

			</el-dialog>

			<!--编辑合同明细的表单-->
			<el-dialog
					width="30%"
					title="编辑合同明细"
					:visible.sync="handleEditContractDetail"
					append-to-body>
				<el-form :model="editDetail" label-width="90px" ref="editDetail" :rules="detailsFormRules">
					<!--格式化时间，可以选择日期和时分秒-->
					<el-form-item label="付款时间" prop="payTime" required>
						<el-date-picker type="datetime" placeholder="请选择时间"
										v-model="editDetail.payTime"
										format="yyyy-MM-dd HH:mm:ss"/>
					</el-form-item>
					<el-form-item label="付款比例(%)">
						<el-input v-model="editDetail.scale" disabled></el-input>
					</el-form-item>
					<el-form-item label="金额(元)" prop="money" required>
						<el-input v-model.number="editDetail.money"></el-input>
					</el-form-item>
					<el-form-item label="是否付款" required prop="isPayment">
						<el-select v-model="editDetail.isPayment" filterable placeholder="请选择" >
							<el-option
									v-for="item in isPaymentList"
									:key="item.value"
									:label="item.label"
									:value="item.value">
							</el-option>
						</el-select>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button @click.native="handleEditContractDetail = false">取消</el-button>
					<el-button type="primary" @click.native="editSubmitDetail" :loading="addLoading">提交</el-button>
				</div>

			</el-dialog>

		</el-dialog>

		<!--编辑界面-->
		<el-dialog title="编辑" :visible.sync="editFormVisible" :close-on-click-modal="false">
			<el-form :model="editForm" label-width="80px" :rules="editFormRules" ref="editForm">
				<!--<el-form-item label="合同单号" prop="sn">
					<el-input v-model="editForm.sn" auto-complete="off"></el-input>
				</el-form-item>-->
				<!--格式化时间，可以选择日期和时分秒-->
				<el-form-item label="签订时间" prop="signTime" required>
					<el-date-picker type="datetime" placeholder="请选择时间"
							v-model="editForm.signTime"
							format="yyyy-MM-dd HH:mm:ss"/>
				</el-form-item>
				<el-form-item label="客户" required prop="customerId">
					<el-select v-model="editForm.customerId" @change="selectCustomerChange2" filterable placeholder="请选择" >
						<el-option
								v-for="item in selectCustomerList"
								:key="item.id"
								:label="item.name"
								:value="item.id">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="营销人员">
					<el-select v-model="editForm.sellerId" @change="selectSellerChange2" filterable placeholder="请选择" >
						<el-option
								v-for="item in selectSellerList"
								:key="item.id"
								:label="item.name"
								:value="item.id">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="总金额" prop="sum">
					<el-input type="sum" v-model.number="editForm.sum"></el-input>
				</el-form-item>
				<el-form-item label="合同摘要">
					<el-input v-model="editForm.intro"></el-input>
				</el-form-item>
				<el-form-item label="所属租户">
					<el-input v-model="editForm.tenant"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="editFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="editSubmit" :loading="editLoading">提交</el-button>
			</div>
		</el-dialog>

		<!--新增界面-->
		<el-dialog title="新增" :visible.sync="addFormVisible" :close-on-click-modal="false">
			<el-form :model="addForm" label-width="80px" :rules="addFormRules" ref="addForm">
				<!--<el-form-item label="合同单号" prop="sn">
					<el-input v-model="addForm.sn" auto-complete="off"></el-input>
				</el-form-item>-->
				<!--格式化时间，可以选择日期和时分秒-->
				<el-form-item label="签订时间" prop="signTime" required>
					<el-date-picker type="datetime" placeholder="请选择时间"
									v-model="addForm.signTime"
									format="yyyy-MM-dd HH:mm:ss"/>
				</el-form-item>
				<el-form-item label="客户" required prop="customerId">
					<el-select v-model="addForm.customerId" @change="selectCustomerChange" filterable placeholder="请选择" >
						<el-option
								v-for="item in selectCustomerList"
								:key="item.id"
								:label="item.name"
								:value="item.id">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="营销人员">
					<el-select v-model="addForm.sellerId" @change="selectSellerChange" filterable placeholder="请选择" >
						<el-option
								v-for="item in selectSellerList"
								:key="item.id"
								:label="item.name"
								:value="item.id">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="总金额" prop="sum">
					<el-input v-model.number="addForm.sum"></el-input>
				</el-form-item>
				<el-form-item label="合同摘要">
					<el-input v-model="addForm.intro"></el-input>
				</el-form-item>
				<el-form-item label="所属租户">
					<el-input v-model="addForm.tenant"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="addFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
			</div>
		</el-dialog>
	</section>
</template>

<script>
	/*git测试,增加此注释*/
	import {addUser, editUser, removeUser} from "../../api/api";
	import util from "../../common/js/util";

	export default {
		data() {
			return {
				filters: {
					sn: '',
					customerName:'',
					startTime:'',
					endTime:''
				},
				contracts: [],
				total: 0,
				page: 1,
				listLoading: false,
				sels: [],//列表选中列

				dialogDetailsVisible:false,//合同明细不显示
				details:[],//合同明细
				contractId:'',//合同id，用于查询合同明细
				contractSum:'',//合同的总金额，用于计算已付金额，和剩余应付金额
				contractTemp:'',

				handleAddContractDetail:false,//默认关闭添加合同明细对话框
				handleEditContractDetail:false,//默认关闭编辑合同明细对话框
				//是否付款的下拉框
				isPaymentList:[
					{
						value:true,
						label:'是'
					},{
						value:false,
						label:'否'
					}
				],
				//新增合同明细界面数据，所占比例应该计算出来
				addDetail:{
					payTime:'',
					money:'',
					/*scale:'',*/
					isPayment:'',
				},
				//新增合同明细界面数据
				editDetail:{
					id:'',
					payTime:'',
					money:'',
					/*scale:'',*/
					isPayment:'',
				},
				detailsFormRules: {
					payTime: { type: 'date', required: true, message: '请选择时间', trigger: 'change' },
					money:[
						{ required: true, message: '请输入金额', trigger: 'blur' },
						{ type: 'number', message: '金额必须为数字值', trigger: 'blur' },
					],
					isPayment:{ required: true, message: '请选择客户', trigger: 'blur' }
				},

				editFormVisible: false,//编辑界面是否显示
				editLoading: false,
				editFormRules: {
					/*sn: [
						{ required: true, message: '请输入名称', trigger: 'blur' }
					],*/
					//前台会显示类型不对报错
					sum:[{
						required: true,
						message: '请输入定金'
					},
						{
							type: 'number',
							message: '金额必须为数字值'
						},

					],
					signTime:{ type: 'date', required: true, message: '请选择时间', trigger: 'change' },
					customerId:{ required: true, message: '请选择客户', trigger: 'blur' }
				},
				//编辑界面数据
				editForm: {
					id: '',
					/*sn: '',*/
					signTime:'',
					sum:'',
					intro:'',
					tenant:'',
					customerId:'',
					sellerId:''
				},

				addFormVisible: false,//新增界面是否显示
				addLoading: false,
				addFormRules: {
					sn: [
						{ required: true, message: '请输入合同单号', trigger: 'blur' }
					],
					sum:[{
						required: true,
						message: '请输入定金'
					},
						{
							type: 'number',
							message: '金额必须为数字值'
						},

					],
					signTime: { type: 'date', required: true, message: '请选择时间', trigger: 'change' },
					customerId:{ required: true, message: '请选择客户', trigger: 'blur' }
				},
				//新增界面数据
				addForm: {
					/*sn: '',*/
					signTime:'',
					sum:'',
					intro:'',
					tenant:'',
					customerId:'',
					sellerId:''
				}

			}
		},
		watch: {//监听
			'editDetail.money'(val){//通过金额，动态计算比例，并显示
				this.editDetail.scale = val/this.contractSum*100;

			},
			'addDetail.money'(val){//通过金额，动态计算比例，并显示
				this.addDetail.scale = val/this.contractSum*100;

			}
		},
		computed: {
			/*setScale(){//通过金额，动态计算比例，并显示
				this.editDetail.scale = this.editDetail.money/this.contractSum*100;

			},*/

			selectCustomerList() {//初始化下拉框动态数据
				let obj = [];
				this.$http.patch("/customer/list").then(res => {
					res.data.forEach((item, index) => {//关键的是将后台返回的数据进行遍历，并封装好
						obj.push({
							id: item.id,//id必须品啊
							name: item.name//name必须品啊
						});
					});
				});
				return obj;
			},
			selectSellerList() {//初始化下拉框动态数据
				let obj = [];
				this.$http.patch("/employee/list").then(res => {
					res.data.forEach((item, index) => {//关键的是将后台返回的数据进行遍历，并封装好
						obj.push({
							id: item.id,//id必须品啊
							name: item.username//name必须品啊
						});
					});
				});
				return obj;
			},
		},
		methods: {
			//格式化是否付款的表格
			/*formatIsPayment(row, column){
				return row.isPayment ? "是" :  "否";
			},*/

			dialogDetails(index,row){
				//合同contractId赋值
				this.contractId = row.id;
				//合同总金额
				this.contractSum = row.sum;
				//打开合同明细对话框
				this.dialogDetailsVisible = true;
				//this.details = row.details;

				this.getDetails();

				/*let temps = row.details;
				//将合同的id和合同编号sn封装到合同明细details中
				for (let i=0;i<temps.length;i++){
					temps[i].contract = {
						"id":row.id,
						"sn":row.sn
					}
				}
				this.details = temps;*/
			},


			//获取销售人员下拉数据,添加数据
			selectSellerChange(val){
				let obj = {};
				obj = this.selectSellerList.find(function(item) {//obj是选中的对象
					return item.id === val;
				});
				/*this.addForm.id = obj.id;//提交数据使用，此处可忽略
				this.addForm.name = obj.name;//用于回显名称*/
			},
			//获取销售人员下拉数据,编辑数据
			selectSellerChange2(val){
				//出现这个问题好像是因为下拉框数据是循环掉别的接口得来的，
				// 因为数据层次太多，render函数没有自动更新，
				// 需手动强制刷新所以我直接强制刷新了值，而forceUpdate就是重新render。
				this.$forceUpdate();
				let obj = {};
				obj = this.selectSellerList.find(function(item) {//obj是选中的对象
					return item.id === val;
				});

			},
			//获取客户下拉数据,添加数据
			selectCustomerChange(val){
				let obj = {};
				obj = this.selectCustomerList.find(function(item) {//obj是选中的对象
					return item.id === val;
				});
				/*this.addForm.id = obj.id;//提交数据使用，此处可忽略
				this.addForm.name = obj.name;//用于回显名称
				console.log(this.addForm.customerId)*/
			},
			//获取合同下拉数据,编辑数据
			selectCustomerChange2(val){
				//出现这个问题好像是因为下拉框数据是循环掉别的接口得来的，
				// 因为数据层次太多，render函数没有自动更新，
				// 需手动强制刷新所以我直接强制刷新了值，而forceUpdate就是重新render。
				this.$forceUpdate();
				let obj = {};
				obj = this.selectCustomerList.find(function(item) {//obj是选中的对象
					return item.id === val;
				});

			},

			//分页信息
			handleCurrentChange(val){
				this.page = val;
				this.getContracts();
			},
			//获取合同明细列表
			getDetails() {
				this.listLoading = true;
				//查询出合同的分页信息
				this.$http.get('/contractPaymentDetails/findByContractId/'+this.contractId).then((res) => {
					this.details = res.data;
					this.listLoading = false;
					//计算合同明细中付款总数，剩余应付金额
					let detailsMoney = 0;//合同明细总金额
					let detailsScale = '';//合同明细总金额所占的比例
					for(let i=0;i<this.details.length;i++){
						if (this.details[i].isPayment){
							detailsMoney += this.details[i].money;
						}
					}
					//已付比例
					detailsScale = (detailsMoney/this.contractSum).toFixed(2)*100;

					//将数据放到中间对象中，以便取出，更新数据后重置
					this.contractTemp = {
						"detailsMoney":detailsMoney,
						"detailsScale":detailsScale
					}


				});

			},
			//清空高级查询框
			getAllDepositOrders(){
				this.page = 1;
				this.filters.sn = '';
				this.filters.customerName = '';
				this.filters.startTime = '';
				this.filters.endTime = '';
				this.getContracts();
			},
			//获取合同列表
			getContracts() {
				let param = {
					"currentPage":this.page,
					"sn":this.filters.sn,
					"customerName":this.filters.customerName,
					"startTime":this.filters.startTime,
					"endTime":this.filters.endTime
				}

				this.listLoading = true;
				//查询出合同的分页信息
				this.$http.patch('/contract/queryPage',param).then((res) => {
					let rows = res.data.rows;
					/*for (let i=0;i<rows.length;i++){
						rows[i].children = rows[i].details;
						console.log("rows[i].children",rows[i].children)
						console.log("rows[i].details",rows[i].details)
					}*/

					this.contracts = rows;
					this.total = res.data.total;
					this.listLoading = false;
				});

			},
			//删除
			handleDel: function (index, row) {
				this.$confirm('确认删除该记录吗?', '提示', {
					type: 'warning'
				}).then(() => {
					this.listLoading = true;
					this.$http.delete('/contract/delete/'+row.id).then((res) => {
						let {success,msg} = res.data;
						this.listLoading = false;
						if (success){
							this.$message({
								message: msg,
								type: 'success'
							});
							this.getContracts();
						}else{
							this.$message({
								message: msg,
								type: 'error'
							});
						}
					});
				}).catch(() => {

				});
			},
			//显示编辑界面
			handleEdit: function (index, row) {
				this.editFormVisible = true;
				this.editForm = Object.assign({}, row);
				//修改页面回显合同
				if (row.customer){
					this.editForm.customerId = row.customer.id;
				}
				if (row.seller){
					this.editForm.sellerId = row.seller.id;
				}
			},
			//显示新增界面
			handleAdd: function () {
				this.addFormVisible = true;

			},
			//编辑
			editSubmit: function () {
				this.$refs.editForm.validate((valid) => {
					if (valid) {
						this.$confirm('确认提交吗？', '提示', {}).then(() => {
							this.editLoading = true;
							//NProgress.start();
							let para = Object.assign({}, this.editForm);

							//封装合同id，以便传入后台
							para.customer = {
								"id":this.editForm.customerId
							};
							//封装销售人员id
							para.seller = {
								"id":this.editForm.sellerId
							};
							/*//如果表单日期没有填写，则默认为当前时间
							if (!this.editForm.signTime){
								this.editForm.signTime = new Date();
							}*/
							this.$http.post('/contract/update',para).then((res) => {
								let {success,msg} = res.data;
								this.editLoading = false;
								if (success){
									this.$message({
										message: msg,
										type: 'success'
									});
									this.$refs['editForm'].resetFields();
									this.editFormVisible = false;
									this.getContracts();
								}else{
									this.$message({
										message: msg,
										type: 'error'
									});
								}
							});
						});
					}
				});
			},
			//新增
			addSubmit: function () {
				this.$refs.addForm.validate((valid) => {
					if (valid) {
						this.$confirm('确认提交吗？', '提示', {}).then(() => {
							this.addLoading = true;
							//NProgress.start();
							let para = Object.assign({}, this.addForm);
							//将合同id绑定到合同对象中
							para.customer = {
								"id":this.addForm.customerId
							};
							//封装销售人员id
							para.seller = {
								"id":this.addForm.sellerId
							};

							this.$http.put('/contract/save',para).then((res) => {
								/*解构*/
								let {success,msg} = res.data;
								this.addLoading = false;
								//判断是否成功
								if (success){
									this.$message({
										message: msg,
										type: 'success'
									});
									/*清空表单*/
									this.$refs['addForm'].resetFields();
									this.addFormVisible = false;
									/*刷新数据*/
									this.getContracts();
								}else {
									this.$message({
										message: msg,
										type: 'error'
									});
								}
							});
						});
					}
				});
			},

			//----------------------------合同明细的增删改-----------------------------------------
			//删除
			handleDelDetail: function (index, row) {
				this.$confirm('确认删除该记录吗?', '提示', {
					type: 'warning'
				}).then(() => {
					this.listLoading = true;
					this.$http.delete("/contractPaymentDetails/delete/"+row.id).then((res) => {
						this.listLoading = false;
						let {success,msg} = res.data;
						if (success){
							this.$message({
								message: msg,
								type: 'success'
							});
							//删除成功后如何刷新对话框
							this.getDetails();
						}else{
							this.$message({
								message: msg,
								type: 'error'
							});
						}
					});
				}).catch(() => {

				});
			},
			//显示编辑界面
			handleEditDetail: function (index, row) {
				this.handleEditContractDetail = true;
				this.editDetail = Object.assign({}, row);

			},
			//显示新增界面
			handleAddDetail: function () {
				this.handleAddContractDetail = true;
			},
			//编辑
			editSubmitDetail: function () {
				this.$refs.editDetail.validate((valid) => {
					if (valid) {
						this.$confirm('确认提交吗？', '提示', {}).then(() => {
							this.editLoading = true;
							//封装表单中的数据，传入后台
							let para = Object.assign({}, this.editDetail);
							this.$http.post("/contractPaymentDetails/update",para).then((res) => {
								this.editLoading = false;
								//解构返回信息
								let {success,msg} = res.data;
								//判断数据是否修改成功
								if (success){
									this.$message({
										message: msg,
										type: 'success'
									});
									this.$refs['editDetail'].resetFields();
									this.handleEditContractDetail = false;
									this.getDetails();
								}else {
									this.$message({
										message: msg,
										type: 'error'
									});
								}
							});
						});
					}
				});
			},
			//新增
			addSubmitDetail: function () {
				this.$refs.addDetail.validate((valid) => {
					if (valid) {
						this.$confirm('确认提交吗？', '提示', {}).then(() => {
							this.addLoading = true;

							let para = Object.assign({}, this.addDetail);
							para.contract = {
								"id":this.contractId
							};

							this.$http.put("/contractPaymentDetails/save",para).then((res) => {
								this.addLoading = false;

								let {success,msg} = res.data;
								if (success){
									this.$message({
										message: msg,
										type: 'success'
									});
									//删除成功后如何刷新对话框
									this.$refs['addDetail'].resetFields();
									this.handleAddContractDetail = false;
									this.getDetails();
								}else{
									this.$message({
										message: msg,
										type: 'error'
									});
								}

							});
						});
					}
				});
			},
			selsChange: function (sels) {
				this.sels = sels;
			}
		},
		mounted() {
			this.getContracts();
		}
	}

</script>

<style>
	input[disabled], input:disabled, input.disabled {
		color: #000000;
		-webkit-text-fill-color: #000000;
		-webkit-opacity: 1;
		opacity: 1;
	}
</style>